This page could contain development features. Please be careful and check what version you are using. Thanks.
This is just another wrapper for highcharts javascript library for R. The mainly motivation to this packages is get a the all the power from HCs API with no restrictions and write the plots using the pipe operator just like metricsgraphics and dygraphs.
Highcharts is very mature javascript charting library and it has a great and powerful API to get a very style of charts and highly customized (see http://www.highcharts.com/demo).
In the package there’s some partial implementation of the HC API in R like hc_title, hc_add_series, hc_xAxis, and some shorcuts to made simples chart in R like hc_add_series_scatter, hc_add_series_scatter by if you want you can create your chart manually with all the requiriments what you need. That’s the package offer.
You can install the package with the usual install.packages("highcharter") or if you want to try new features before the updates: via devtools devtools::install_github("jbkunst/highcharter").
I think there are 4 key parts to work with this package:
hchart() function. This function can chart various R objects on the fly with one line of code. The resulting chart is a highchart object so you can keep modifying with the API.Let’s start doing a simple column chart:
library("highcharter")
hc <- highchart() %>%
hc_title(text = "A nice chart") %>%
hc_add_series(data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
26.5, 23.3, 18.3, 13.9, 9.6))
hc
If you are not familiar with the magrittr pipe operator (%>%), here is the equivalent without using pipes:
hc <- highchart()
hc <- hc_title(hc, text = "A nice chart")
hc <- hc_add_series(hc, data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
26.5, 23.3, 18.3, 13.9, 9.6))
hc
With the implemented API you can modify the previous chart in a easy way. Let’s do some changes:
hc <- hc %>%
hc_title(style = list(color = "red")) %>%
hc_subtitle(text = "I want to add a subtitle too with style",
style = list(color = "#B71C1C", fontWeight = "bold")) %>%
hc_xAxis(categories = c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) %>%
hc_add_series(name = "A another data", type = "column", color = "#1FA67A",
dataLabels = list(align = "center", enabled = TRUE),
data = c(3.9, 4.2, 5.7, 8.5, 11.9, 15.2,
17.0, 16.6, 14.2, 10.3, 6.6, 4.8)) %>%
hc_tooltip(crosshairs = TRUE, shared = TRUE) %>%
hc_yAxis(minorGridLineWidth = 0, gridLineWidth = 0,
plotBands = list(
list(from = 20, to = 30, color = "rgba(68, 170, 213, 0.1)",
label = list(text = "A band from 20 to 30")),
list(from = 10, to = 20, color = "rgba(0, 0, 0, 0.1)",
label = list(text = "Another band"))
))
hc
Easy right? Well, it’s just the Highcharts API. Thanks to the http://www.highcharts.com/ team.
library("quantmod")
x <- getSymbols("AAPL", auto.assign = FALSE)
y <- getSymbols("AMZN", auto.assign = FALSE)
z <- getSymbols("YHOO", auto.assign = FALSE)
highchart() %>%
hc_add_series_ohlc(x) %>%
hc_add_series_ohlc(y, type = "ohlc") %>%
hc_add_series_ohlc(z, type = "line")
library("viridisLite")
library("dplyr")
data(unemployment)
data(uscountygeojson)
dclass <- data_frame(from = seq(0, 10, by = 2),
to = c(seq(2, 10, by = 2), 50),
color = substring(viridis(length(from), option = "C"), 0, 7))
dclass <- list.parse3(dclass)
highchart() %>%
hc_title(text = "US Counties unemployment rates, April 2015") %>%
hc_add_series_map(uscountygeojson, unemployment,
value = "value", joinBy = "code") %>%
hc_colorAxis(dataClasses = dclass) %>%
hc_legend(layout = "vertical", align = "right",
floating = TRUE, valueDecimals = 0,
valueSuffix = "%") %>%
hc_mapNavigation(enabled = TRUE)
Premise: There’s not default arguments. All arguments need to be named.
Let’s use a simple plot to show how do with the differentes funcions from the package.
data(citytemp)
citytemp
| month | tokyo | new_york | berlin | london |
|---|---|---|---|---|
| Jan | 7.0 | -0.2 | -0.9 | 3.9 |
| Feb | 6.9 | 0.8 | 0.6 | 4.2 |
| Mar | 9.5 | 5.7 | 3.5 | 5.7 |
| Apr | 14.5 | 11.3 | 8.4 | 8.5 |
| May | 18.2 | 17.0 | 13.5 | 11.9 |
| Jun | 21.5 | 22.0 | 17.0 | 15.2 |
| Jul | 25.2 | 24.8 | 18.6 | 17.0 |
| Aug | 26.5 | 24.1 | 17.9 | 16.6 |
| Sep | 23.3 | 20.1 | 14.3 | 14.2 |
| Oct | 18.3 | 14.1 | 9.0 | 10.3 |
| Nov | 13.9 | 8.6 | 3.9 | 6.6 |
| Dec | 9.6 | 2.5 | 1.0 | 4.8 |
hc <- highchart() %>%
hc_xAxis(categories = citytemp$month) %>%
hc_add_series(name = "Tokyo", data = citytemp$tokyo) %>%
hc_add_series(name = "London", data = citytemp$london) %>%
hc_add_series(name = "Other city",
data = (citytemp$tokyo + citytemp$london)/2)
hc
With hc_chart you can define general chart options.
hc %>%
hc_chart(borderColor = '#EBBA95',
borderRadius = 10,
borderWidth = 2,
backgroundColor = list(
linearGradient = c(0, 0, 500, 500),
stops = list(
list(0, 'rgb(255, 255, 255)'),
list(1, 'rgb(200, 200, 255)')
)))
Now change type to colum and add 3d effect.
hc <- hc %>%
hc_chart(type = "column",
options3d = list(enabled = TRUE, beta = 15, alpha = 15))
hc
Now remove 3deffect and add the original type to work with the next examples.
hc <- hc_chart(hc, type = "line", options3d = list(enabled = FALSE))
This functions allow between other things:
hc %>%
hc_xAxis(title = list(text = "Month in x Axis"),
opposite = TRUE,
plotLines = list(
list(label = list(text = "This is a plotLine"),
color = "#FF0000",
width = 2,
value = 5.5))) %>%
hc_yAxis(title = list(text = "Temperature in y Axis"),
opposite = TRUE,
minorTickInterval = "auto",
minorGridLineDashStyle = "LongDashDotDot",
showFirstLabel = FALSE,
showLastLabel = FALSE,
plotBands = list(
list(from = 25, to = htmlwidgets::JS("Infinity"), color = "rgba(100, 0, 0, 0.1)",
label = list(text = "This is a plotBand"))))
hc <- highchart() %>%
hc_xAxis(categories = citytemp$month) %>%
hc_add_series(name = "Tokyo", data = citytemp$tokyo) %>%
hc_add_series(name = "New York", data = citytemp$new_york)
hc
hc %>%
hc_add_series(name = "London", data = citytemp$london, type = "area") %>%
hc_rm_series(name = "New York")
Functions to modify the chart’s main title, subtitle, credits, legend and tooltip.
hc %>%
hc_title(text = "This is a title with <i>margin</i> and <b>Strong or bold text</b>",
margin = 20, align = "left",
style = list(color = "#90ed7d", useHTML = TRUE)) %>%
hc_subtitle(text = "And this is a subtitle with more information",
align = "left",
style = list(color = "#2b908f", fontWeight = "bold")) %>%
hc_credits(enabled = TRUE, # add credits
text = "www.lonk.tomy.site",
href = "http://jkunst.com") %>%
hc_legend(align = "left", verticalAlign = "top",
layout = "vertical", x = 0, y = 100) %>%
hc_tooltip(crosshairs = TRUE, backgroundColor = "#FCFFC5",
shared = TRUE, borderWidth = 5) %>%
hc_exporting(enabled = TRUE) # enable exporting option
highchart() %>%
hc_title(text = "Simple scatter chart") %>%
hc_add_series_scatter(mtcars$wt, mtcars$mpg)
highchart() %>%
hc_title(text = "Scatter chart with color") %>%
hc_add_series_scatter(mtcars$wt, mtcars$mpg,
color = mtcars$hp)
highchart() %>%
hc_title(text = "Scatter chart with size") %>%
hc_add_series_scatter(mtcars$wt, mtcars$mpg,
mtcars$drat)
highchart() %>%
hc_title(text = "Scatter chart with size and color") %>%
hc_add_series_scatter(mtcars$wt, mtcars$mpg,
mtcars$drat, mtcars$hp)
highchart(height = 500) %>%
hc_title(text = "A complete example for Scatter") %>%
hc_add_series_scatter(mtcars$wt, mtcars$mpg,
mtcars$drat, mtcars$hp,
rownames(mtcars),
dataLabels = list(
enabled = TRUE,
format = "{point.label}"
)) %>%
hc_chart(zoomType = "xy") %>%
hc_tooltip(useHTML = TRUE,
headerFormat = "<table>",
pointFormat = paste("<tr><th colspan=\"1\"><b>{point.label}</b></th></tr>",
"<tr><th>Weight</th><td>{point.x} lb/1000</td></tr>",
"<tr><th>MPG</th><td>{point.y} mpg</td></tr>",
"<tr><th>Drat</th><td>{point.z} </td></tr>",
"<tr><th>HP</th><td>{point.valuecolor} hp</td></tr>"),
footerFormat = "</table>")
Or we can add series one by one.
hc <- highchart()
for (cyl in unique(mtcars$cyl)) {
hc <- hc %>%
hc_add_series_scatter(mtcars$wt[mtcars$cyl == cyl],
mtcars$mpg[mtcars$cyl == cyl],
name = sprintf("Cyl %s", cyl),
showInLegend = TRUE)
}
hc
If you use time series object with Hicharts you can enabled the Highstock which include sophisticated navigation options like a small navigator series, preset date ranges, date picker, scrolling and panning.
data(economics, package = "ggplot2")
highchart() %>%
hc_add_series_times_values(economics$date, economics$psavert,
name = "Personal Savings Rate")
Same data but using highstock instead of highcharts.
highchart(type = "stock") %>%
hc_title(text = "US economic time series") %>%
hc_subtitle(text = "This dataset was produced from US economic time series data available") %>%
hc_tooltip(valueDecimals = 2) %>%
hc_add_series_times_values(economics$date,
economics$psavert,
name = "Personal savings rate") %>%
hc_add_series_times_values(economics$date,
economics$uempmed,
name = "Median duration of unemployment") %>%
hc_add_theme(hc_theme_sandsignika()) # see more about themes below.
ts objectsThere’s a hc_add_series_ts which recieve a ts object.
highchart() %>%
hc_add_series_ts(AirPassengers, color = "#26838E")
highchart(type = "stock") %>%
hc_title(text = "Monthly Deaths from Lung Diseases in the UK") %>%
hc_subtitle(text = "Deaths from bronchitis, emphysema and asthma") %>%
hc_add_series_ts(fdeaths, name = "Female") %>%
hc_add_series_ts(mdeaths, name = "Male")
xts objectsSupport ohlc series from the quantmod package. You can also add markes or flag with hc_add_series_flags:
library("quantmod")
x <- getSymbols("AAPL", auto.assign = FALSE)
y <- getSymbols("SPY", auto.assign = FALSE)
highchart() %>%
hc_add_series_ohlc(x) %>%
hc_add_series_ohlc(y)
usdjpy <- getSymbols("USD/JPY", src = "oanda", auto.assign = FALSE)
eurkpw <- getSymbols("EUR/KPW", src = "oanda", auto.assign = FALSE)
dates <- as.Date(c("2015-05-08", "2015-09-12"), format = "%Y-%m-%d")
highchart(type = "stock") %>%
hc_add_series_xts(usdjpy, id = "usdjpy") %>%
hc_add_series_xts(eurkpw, id = "eurkpw") %>%
hc_add_series_flags(dates, title = c("E1", "E2"),
text = c("This is event 1",
"This is the event 2"),
id = "usdjpy") %>%
hc_rangeSelector(inputEnabled = FALSE) %>%
hc_scrollbar(enabled = FALSE) %>%
hc_add_theme(hc_theme_gridlight())
Here we use the treemap package to create a treemap object and then we create the same treemap via highcharts ;).
library("treemap")
library("viridisLite")
data(GNI2010)
tm <- treemap(GNI2010, index = c("continent", "iso3"),
vSize = "population", vColor = "GNI",
type = "value", palette = viridis(6))
hc_tm <- highchart(height = 800) %>%
hc_add_series_treemap(tm, allowDrillToNode = TRUE,
layoutAlgorithm = "squarified",
name = "tmdata") %>%
hc_title(text = "Gross National Income World Data") %>%
hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
Pop: {point.value:,.0f}<br>
GNI: {point.valuecolor:,.0f}")
hc_tm
hc_tm <- hc_rm_series(hc_tm, name = "tmdata")
Change the type parameter.
tm <- treemap(GNI2010, index = c("continent", "iso3"),
vSize = "population", vColor = "GNI",
type = "comp", palette = rev(viridis(6)))
hc_tm %>%
hc_add_series_treemap(tm, allowDrillToNode = TRUE,
layoutAlgorithm = "squarified")
data("favorite_bars")
data("favorite_pies")
highchart() %>%
hc_title(text = "This is a bar graph describing my favorite pies
including a pie chart describing my favorite bars") %>%
hc_subtitle(text = "In percentage of tastiness and awesomeness") %>%
hc_add_series_labels_values(favorite_pies$pie, favorite_pies$percent, name = "Pie",
colorByPoint = TRUE, type = "column") %>%
hc_add_series_labels_values(favorite_bars$bar, favorite_bars$percent,
colors = substr(terrain.colors(5), 0 , 7), type = "pie",
name = "Bar", colorByPoint = TRUE, center = c('35%', '10%'),
size = 100, dataLabels = list(enabled = FALSE)) %>%
hc_yAxis(title = list(text = "percentage of tastiness"),
labels = list(format = "{value}%"), max = 100) %>%
hc_xAxis(categories = favorite_pies$pie) %>%
hc_legend(enabled = FALSE) %>%
hc_tooltip(pointFormat = "{point.y}%")
data(worldgeojson)
data(GNI2010, package = "treemap")
head(GNI2010)
| iso3 | country | continent | population | GNI |
|---|---|---|---|---|
| ABW | Aruba | North America | 108 | 0 |
| AFG | Afghanistan | Asia | 34385 | 410 |
| AGO | Angola | Africa | 19082 | 3960 |
| ALB | Albania | Europe | 3205 | 3960 |
| ARE | United Arab Emirates | Asia | 7512 | 0 |
| ARG | Argentina | South America | 40412 | 8620 |
highchart() %>%
hc_add_series_map(worldgeojson, GNI2010,
value = "GNI", joinBy = "iso3")
Other fun example. Load various geojson and chart them all.
library("httr")
world <- "https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json" %>%
GET() %>%
content() %>%
jsonlite::fromJSON(simplifyVector = FALSE)
# http://cedeusdata.geosteiniger.cl/layers/geonode:mundo_corrientes_maritimas
marine <- "http://cedeusdata.geosteiniger.cl/geoserver/wfs?srsName=EPSG%3A4326&typename=geonode%3Amundo_corrientes_maritimas&outputFormat=json&version=1.0.0&service=WFS&request=GetFeature" %>%
GET() %>%
content()
# http://cedeusdata.geosteiniger.cl/layers/geonode:mundo_limites_placas
plates <- "http://cedeusdata.geosteiniger.cl/geoserver/wfs?srsName=EPSG%3A4326&typename=geonode%3Amundo_limites_placas&outputFormat=json&version=1.0.0&service=WFS&request=GetFeature" %>%
GET() %>%
content()
# http://cedeusdata.geosteiniger.cl/layers/geonode:mundo_volcanes
volcano <- "http://cedeusdata.geosteiniger.cl/geoserver/wfs?srsName=EPSG%3A4326&typename=geonode%3Amundo_volcanes&outputFormat=json&version=1.0.0&service=WFS&request=GetFeature" %>%
GET() %>%
content()
highchart(type = "map", debug = TRUE) %>%
hc_add_series(mapData = world, showInLegend = FALSE) %>%
hc_add_series(data = marine, type = "mapline", lineWidth = 2,
name = "Marine currents", color = 'rgba(0, 0, 80, 0.5)',
states = list(hover = list(color = "#BADA55")),
tooltip = list(pointFormat = "{point.properties.NOMBRE}")) %>%
hc_add_series(data = plates, type = "mapline",
name = "Plates", color = 'rgba(10, 10, 10, 0.5)',
tooltip = list(pointFormat = "{point.properties.TIPO}")) %>%
hc_add_series(data = volcano, type = "mappoint",
name = "Volcanos", color = 'rgba(255, 0, 80, 0.5)',
tooltip = list(pointFormat = "{point.properties.NOMBRE}")) %>%
hc_mapNavigation(enabled = TRUE) %>%
hc_title(text = "Testing geojson format")
hchart() functionRight now there are some R object to plot wiht this generic function.
Think like ggplot. The resulting chart is a highchart object so you can modify attributes like titles, tootlips or add themes.
x <- c(rnorm(500), rnorm(500, 6, 2))
class(x)
## [1] "numeric"
hist(x, breaks = "FD") # by default hchart use *Freedman-Diaconis* rule
hchart(x)
x <- hist(rbeta(300, 0.2, 4), plot = FALSE)
class(x)
## [1] "histogram"
plot(x) # by default hchart use *Freedman-Diaconis* rule
hchart(x)
data(diamonds, package = "ggplot2")
x <- diamonds$cut
class(x)
## [1] "ordered" "factor"
plot(x)
hchart(x)
hchart(as.character(x), type = "pie")
x <- LakeHuron
class(x)
## [1] "ts"
plot(x)
hchart(x)
library("quantmod")
x <- getSymbols("USD/JPY", src = "oanda", auto.assign = FALSE)
class(x)
## [1] "xts" "zoo"
plot(x)
hchart(x)
x <- getSymbols("YHOO", auto.assign = FALSE)
class(x)
## [1] "xts" "zoo"
plot(x)
hchart(x)
x <- acf(diff(AirPassengers), plot = FALSE)
class(x)
## [1] "acf"
plot(x)
hchart(x)
x <- cbind(mdeaths, fdeaths)
class(x)
## [1] "mts" "ts" "matrix"
plot(x)
hchart(x)
x <- dist(mtcars[ order(mtcars$hp),])
class(x)
## [1] "dist"
plot(x)
hchart(x)
hc <- highchart() %>%
hc_title(text = "Motor Trend Car Road Tests") %>%
hc_subtitle(text = "Source: 1974 Motor Trend US magazine") %>%
hc_xAxis(title = list(text = "Weight")) %>%
hc_yAxis(title = list(text = "Miles/gallon")) %>%
hc_chart(zoomType = "xy") %>%
hc_add_series_scatter(mtcars$wt, mtcars$mpg,
mtcars$drat, mtcars$hp,
rownames(mtcars),
dataLabels = list(
enabled = TRUE,
format = "{point.label}"
)) %>%
hc_tooltip(useHTML = TRUE,
headerFormat = "<table>",
pointFormat = paste("<tr><th colspan=\"1\"><b>{point.label}</b></th></tr>",
"<tr><th>Weight</th><td>{point.x} lb/1000</td></tr>",
"<tr><th>MPG</th><td>{point.y} mpg</td></tr>",
"<tr><th>Drat</th><td>{point.z} </td></tr>",
"<tr><th>HP</th><td>{point.valuecolor} hp</td></tr>"),
footerFormat = "</table>")
hc
hc %>% hc_add_theme(hc_theme_darkunica())
hc %>% hc_add_theme(hc_theme_gridlight())
hc %>% hc_add_theme(hc_theme_sandsignika())
Insipired in https://www.amcharts.com/inspiration/chalk/
hc %>% hc_add_theme(hc_theme_chalk())
hc %>% hc_add_theme(hc_theme_null())
thm <- hc_theme(
colors = c('red', 'green', 'blue'),
chart = list(
backgroundColor = NULL,
divBackgroundImage = "http://media3.giphy.com/media/FzxkWdiYp5YFW/giphy.gif"
),
title = list(
style = list(
color = '#333333',
fontFamily = "Erica One"
)
),
subtitle = list(
style = list(
color = '#666666',
fontFamily = "Shadows Into Light"
)
),
legend = list(
itemStyle = list(
fontFamily = 'Tangerine',
color = 'black'
),
itemHoverStyle = list(
color = 'gray'
)
)
)
hc %>% hc_add_theme(thm)
thm <- hc_theme_merge(
hc_theme_darkunica(),
hc_theme(
chart = list(
backgroundColor = "transparent",
divBackgroundImage = "http://cdn.wall-pix.net/albums/art-3Dview/00025095.jpg"
),
title = list(
style = list(
color = 'white',
fontFamily = "Erica One"
)
)
)
)
hc %>% hc_add_theme(thm)
Example in http://www.highcharts.com/
rainfall <- c(49.9, 71.5, 106.4, 129.2, 144, 176,
135.6, 148.5, 216.4, 194.1, 95.6, 54.4)
temperature <- c(7, 6.9, 9.5, 14.5, 18.2, 21.5,
25.2, 26.5, 23.3, 18.3, 13.9, 9.6)
col1 <- hc_get_colors()[3]
col2 <- hc_get_colors()[2]
highchart() %>%
hc_title(text = "Tokyo Climate") %>%
hc_legend(enabled = FALSE) %>%
hc_xAxis(categories = month.abb) %>%
hc_yAxis(
list(
title = list(text = "Temperature"),
align = "left",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} °C", useHTML = TRUE)
),
list(
title = list(text = "Rainfall"),
align = "right",
showFirstLabel = FALSE,
showLastLabel = FALSE,
labels = list(format = "{value} mm"),
opposite = TRUE
)
) %>%
#
hc_tooltip(formatter = htmlwidgets::JS("function(){
if('Sunshine' == this.series.name){
return '<b>' + this.point.name + ': </b>' + this.y
} else {
unts = this.series.name == 'Rainfall' ? 'mm' : '°C';
return (this.x + ': ' + this.y + ' ' + unts)
}}"),
useHTML = TRUE) %>%
hc_add_series(name = "Rainfall", type = "column",
data = rainfall, yAxis = 1) %>%
hc_add_series(name = "Temperature", type = "spline",
data = temperature) %>%
hc_add_series(name = "Sunshine", type = "pie",
data = list(list(y = 2020, name = "Sunshine hours",
sliced = TRUE, color = col1),
list(y = 6740, name = "Non sunshine hours (including night)",
color = col2,
dataLabels = list(enabled = FALSE))),
center = c('20%', 45),
size = 80)
nyears <- 5
df <- expand.grid(seq(12) - 1, seq(nyears) - 1)
df$value <- abs(seq(nrow(df)) + 10 * rnorm(nrow(df))) + 10
df$value <- round(df$value, 2)
ds <- list.parse2(df)
hc <- highchart() %>%
hc_chart(type = "heatmap") %>%
hc_title(text = "Simulated values by years and months") %>%
hc_xAxis(categories = month.abb) %>%
hc_yAxis(categories = 2016 - nyears + seq(nyears)) %>%
hc_add_series(name = "value", data = ds)
hc_colorAxis(hc, minColor = "#FFFFFF", maxColor = "#434348")
require("viridisLite")
n <- 4
stops <- data.frame(q = 0:n/n,
c = substring(viridis(n + 1), 0, 7))
stops <- list.parse2(stops)
hc_colorAxis(hc, stops = stops, max = 75)
data(diamonds, package = "ggplot2")
df <- dplyr::count(diamonds, cut)
df
| cut | n |
|---|---|
| Fair | 1610 |
| Good | 4906 |
| Very Good | 12082 |
| Premium | 13791 |
| Ideal | 21551 |
df <- setNames(df, c("name", "value"))
ds <- list.parse3(df)
highchart() %>%
hc_title(text = "A simple Treemap") %>%
hc_add_series(data = ds, type = "treemap", colorByPoint = TRUE)
Similar input like chordEx1 example in http://yihui.name/recharts/
hc_opts <- list()
hc_opts$title <- list(text = "This is a title", x = -20)
hc_opts$xAxis <- list(categories = c('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))
hc_opts$series <- list(list(name = "Tokyo",
data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5,
25.2, 26.5, 23.3, 18.3, 13.9, 9.6)))
hc_opts$series <- append(hc_opts$series,
list(list(name = "New York",
type = "spline",
lineWidth = 5,
data = c(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0,
24.8, 24.1, 20.1, 14.1, 8.6, 2.5),
dataLabels = list(align = "left", enabled = TRUE))))
highchart(hc_opts)
hc_opts <- list()
hc_opts$chart <- list(type = "bar")
hc_opts$title <- list(title = "Stacked bar")
hc_opts$xAxis <- list(categories = c('Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'))
hc_opts$yAxis <- list(min = 0, title = list(text = 'Total Fruit Consumtion'))
hc_opts$legend <- list(reversed = TRUE)
hc_opts$series <- list(list(name = "John", data = c(5, 3, 4, 7, 2)),
list(name = "Jane", data = c(2, 2, 3, 2, 1)),
list(name = "Joe", data = c(3, 4, 4, 2, 5)))
highchart(hc_opts, theme = hc_theme_darkunica())